package example2;

import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class URLTest {
    public static void main(String args[]) {
        try {
            URL url = new URL("http://www.qq.com?i=1");
            //只需要输入
            InputStream inputStream = url.openStream();
            //既要输入也要输出 用连接
            URLConnection urlConnection = url.openConnection();


            System.out.println(url.getPort());
            System.out.println(url.getProtocol());
            System.out.println(url.getPath());
            System.out.println(url.getFile());
            System.out.println(url.getQuery());
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}



